package zero;

import java.io.File;
import java.io.IOException;
import java.util.List;

import zero.lex.Lex;
import zero.lex.Token;
import zero.semantic.Semantic;
import zero.slr.Parser;

public class Main {
    public static void main(String[] args) throws IOException {
        Lex    lex     = Lex.getInstance();
        File   srcFile = new File("test1.txt"); // 被分析的源代码文件
        Parser parser  = Parser.getInstance();

        lex.init();
        parser.init();

        List<Token> tokenList = lex.analyze(srcFile);

        System.out.println("\n************ 词法分析结果 ************");
        for (Token t : tokenList) {
            System.out.println("[" + t.getContent() + "\t" + t.getId() + "]");
        }

        System.out.println("\n************ 语法分析结果 ************");
        parser.analyze(tokenList);

        System.out.println("\n************ 语义分析结果 ************");
        Semantic semantic = new Semantic(tokenList);
        semantic.analyze();
    }
}